<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ES6模块化</title>
</head>
<body>
    <!--需要指定type-->
    <script type="module">
        //引入module1.js模块内容

        //1.通用导入方式
        import * as m1 from "./module1.js"
        console.log(m1)
        console.log(m1.school)
        m1.teach()

        import * as m2 from "./module2.js"
        console.log(m2)
        console.log(m2.school)
        m2.findJob()

        
        import * as m3 from "./module3.js"
        console.log(m3)
        console.log(m3.default.school)
        m3.default.findJob()

        //2.解构赋值形式
        import {school, teach} from "./module1.js"
        console.log(school)
        teach()
        //变量不能重名，可以指定别名
        import {school as sgg, findJob} from "./module2.js"
        console.log(sgg)
        findJob()

        import {default as obj} from "./module3.js"
        console.log(obj)

        //3.简便形式 只针对默认暴露
        import obj2 from "./module3.js"
        console.log(obj2)
    </script>
</body>
</html>